#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N=65;
int arr[N],vis[N]; 
int n,sum;
int length;
bool dfs(int u,int cur,int start)
{
	if(u*length==sum)
		return true;
	if(cur==length)
		return dfs(u+1,0,0);
	
	for(int i=start;i<n;i++)
	{
		if(vis[i] || cur+arr[i]>length)
			continue;
		
		vis[i]=1;
		if(dfs(u,cur+arr[i],i+1))
			return true;
		vis[i]=0;
		if(!cur || cur+arr[i]==length)
			return false;
		int j=i;
		while(j<n && arr[i]==arr[j])
			j++;
		i=j-1;
	}
	return false;
}
int main()
{
	while(cin>>n,n)
	{
		sum=0;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			sum+=arr[i];
		}	
		sort(arr,arr+n,[](int& a1,int&a2){
			return a1>a2;
		});
		memset(vis,0,sizeof(vis));
		length=1;
		while(1)
		{
			if(sum%length==0 && dfs(0,0,0))
			{
				cout<<length<<endl;
				break;
			}
			length++;
		}
	}
	return 0;
}
